<template>
  <a-select allow-clear v-bind="$attrs" v-model="currentValue" @change="handleChange">
    <template v-for="item in options">
      <a-select-option :key="item.id" :value="item.id"> {{ item.name }} </a-select-option>
    </template>
  </a-select>
</template>

<script>
import { ACTIVITY_LIST } from '@/const/const'
export default {
  props: {
    value: {
      type: [String, Number],
      default: ''
    },
    type: {
      type: [String],
      default: 'H5'
    }
  },
  data () {
    return {
      currentValue: this.value,
      options: ACTIVITY_LIST[this.type]
    }
  },
  methods: {
    handleChange (val) {
      this.$emit('input', val)
    }
  },
  watch: {
    value (val) {
      this.currentValue = val
    },
    type (val) {
      if (val) {
        this.options = ACTIVITY_LIST[val]
      }
    }
  }
}
</script>
